<template>
  <div class="page-scan-mana">
    <el-form :inline="true" :model="dataQueryForm" ref="dataQueryForm">
      <div class="pc-page-header">
        <el-form-item>
          <el-date-picker type="datetime" size="medium" align="left" v-model="dataQueryForm.startDate" clearable
                          format="yyyy-MM-dd HH:mm" value-format="yyyy-MM-dd HH:mm"  placeholder="选择开始时间">
          </el-date-picker>
          <el-date-picker type="datetime" size="medium" align="left" v-model="dataQueryForm.endDate" clearable
                          format="yyyy-MM-dd HH:mm" value-format="yyyy-MM-dd HH:mm"  placeholder="选择结束时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="">
          <el-button type="primary" @click="queryDataFn">查询</el-button>
          <el-button type="primary" @click="refresh('dataQueryForm')">刷新</el-button>
        </el-form-item>
      </div>
    </el-form>

    <!--列表数据-->
    <egrid border class="page-list"
           :data="tableData"
           :columns="columns"
           :columns-schema="columnsSchema"
           :columns-props="columnsProps">
    </egrid>

    <!--分页组件-->
    <div class="pc-pagination-panel">
      <pc-pagination ref="pcPagination" :url="pageUrl.queryDataList" :queryData="dataQueryForm"
                     @on-query="queryCallBackFn" :pageSizes="[10]">
      </pc-pagination>
    </div>

  </div>
</template>

<script type="text/ecmascript-6">
  import PcPagination from 'components/form/pagination';
  import PcButton from 'components/form/button';
  import PcDialog from 'components/dialog';
  import EgridCellView from 'components/wms/comm/EgridCellView.vue';

  export default {
    props: ['rateName'],
    data() {
      return {
        dataQueryForm: {
          rateName: this.rateName,
          startDate: null,
          endDate: null
        },
        tableData: [],
        columns: [
          {
            label: '货币对',
            prop: 'rateName'
          },
          {
            label: '更新时间',
            prop: 'createdTime'
          },
          {
            label: '现价',
            prop: 'rate'
          }
        ],
        columnsSchema: {
        },
        selecetedRows: [],
        // columnsProps 用于定义所有 columns 公共的属性，
        // 这里属性可以参考这里： http://element.eleme.io/#/zh-CN/component/table#table-column-attributes
        columnsProps: {
          height: 40,
          minWidth: 60,
          showOverflowTooltip: true,
          component: EgridCellView
        },
        // columnsHandler 可用于在现有的 columns 进行操作，对 columns 进行增删改，这里新增了操作列
        pageUrl: {
          queryDataList: '/malisk/server/macro/queryMacroExchangeHistory'
        }
      };
    },
    components: {
      PcPagination, PcButton, PcDialog
    },
    created() {
    },

    methods: {
      // 表头样式
      getHeaderStyle({row, column, rowIndex, columnIndex}) {
        if (rowIndex === 0) {
          return 'background: #f5f5f5; height: 50px';
        } else {
          return '';
        }
      },
      getRowClass({row, column, rowIndex, columnIndex}) {
        if (rowIndex === 0) {
          return 'background:rgb(245, 245, 245);';
        } else {
          return '';
        }
      },
      openMessage() {
        this.$notify.info({
          title: '自定义位置',
          message: '右下角弹出的消息',
          position: 'bottom-right'
        });
      },
      queryCallBackFn(res) {
        this.tableData = res.result.list;
      },
      queryDataFn() {
        this.$refs.pcPagination.queryListWithPageFn(true);
      },
      refresh(formName) {
        this.$refs[formName].resetFields();
        this.dataQueryForm.rateName = this.rateName;
        this.dataQueryForm.startDate = null;
        this.dataQueryForm.endDate = null;
        this.queryDataFn();
      }
    }
  };
</script>
<style>
</style>
